package com.zzy.springbook.controller;


import jakarta.servlet.http.HttpSession;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/user")
public class UserController {
    @RequestMapping("/login")
    public boolean login(String userName, String password, HttpSession session){
        //检查参数
        if(!StringUtils.hasLength(userName)||!StringUtils.hasLength(password)){
            return false;
        }
        //检验这个密码是不是正确的
        if("admin".equals(userName)&&"admin".equals(password)){
            session.setAttribute("userName",userName);
            return true;
        }
        return false;
    }
}
